package com.wanlong.common.result;

import java.io.Serializable;
import java.util.List;

/**
 * @author 万龙
 * @name
 * @project_name wanlong
 * @package_name com.wanlong.common.result
 * @description
 * @date 2019/3/10
 */
public class VueResult<T> implements Serializable {
    public static final String DEFAULT_IMG="https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif";

    private static final long serialVersionUID = 1L;

    public static final String SUCCESS = "0000";
    public static final String FAILURE = "-1";

    private String code;

    private String message;

    private String token;

    private String name;

    private String introduction;

    private String avatar;

    private List<String> roles;

    private T data;

    public VueResult() {
    }

    public VueResult(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }


    public VueResult(String code, String message,String token, String name, String introduction, String avatar, List<String> roles) {
        this.code = code;
        this.message = message;
        this.token = token;
        this.name = name;
        this.introduction = introduction;
        this.avatar = avatar;
        this.roles = roles;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public List<String> getRoles() {
        return roles;
    }

    public void setRoles(List<String> roles) {
        this.roles = roles;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> VueResult<T> failure(String msg){
        return new VueResult<T>(FAILURE,msg,null);
    }

    public static<T> VueResult<T> success(){
        return new VueResult<T>(VueResult.SUCCESS,"操作成功",null);
    }

    public static<T> VueResult<T> success(T data){
        return new VueResult<T>(VueResult.SUCCESS,"操作成功",data);
    }

    public static<T> VueResult<T> success(String token, String name, String introduction, String avatar, List<String> roles){
        return new VueResult<T>(VueResult.SUCCESS,"操作成功",token,name,introduction,avatar,roles);
    }


}
